
        var mouseX,mouseY;
        var chasingMouse = autoAppearing = null;
        var windowWidth;
        var exampleStyleUpdating = watchWidth = null; 
       
        function showSonMenu(){
            if($('main .cases .contnHead .casesNav>li').length <= 1) return false;
            if(window.innerWidth >= 768){
                var html = $('main .cases .contnHead .casesNav>li.current .sonMenu ul').html();
                var index = $('main .cases .contnHead .casesNav>li.current')[0].ind;
                
                console.log(html);
                if(index < 4){
                    $('main .cases .contnHead .casesNav .sonNavPalace').removeClass('now');
                    $('main .cases .contnHead .casesNav .sonNavPalace:eq(0)').addClass('now');
                    if(index < 2){
                        $('main .cases .contnHead .casesNav .sonNavPalace.now').removeClass('end');
                        var padding = 'padding-left:' + 'calc(' + index * 25 + '%' + ' + ';
                        padding += ($('main .cases .contnHead .casesNav>li.current .fNav .line').width() + parseFloat($('main .cases .contnHead .casesNav>li.current .fNav .line').css('margin-right'))) + 'px)';
                    }else{
                        $('main .cases .contnHead .casesNav .sonNavPalace.now').addClass('end');
                        var padding = 'padding-right:' + 'calc(' + (3 - index) * 25 + '%' + ' + ';
                        padding += ($('main .cases .contnHead .casesNav>li.current .fNav').width() - $('main .cases .contnHead .casesNav>li.current .fNav .line').width() - parseFloat($('main .cases .contnHead .casesNav>li.current .fNav .line').css('margin-right'))) - $('main .cases .contnHead .casesNav>li.current .fNav em').width() * 1.2 + 'px)'; 
                        
                    }
                }else{
                    $('main .cases .contnHead .casesNav .sonNavPalace').removeClass('now');
                    $('main .cases .contnHead .casesNav .sonNavPalace:eq(1)').addClass('now');
                    $('main .cases .contnHead .casesNav .sonNavPalace.now').removeClass('end');
                    var padding = 'padding-left:' + 'calc(' + (index - 4) * 25 + '%' + ' + ';
                    padding += ($('main .cases .contnHead .casesNav>li.current .fNav .line').width() + parseFloat($('main .cases .contnHead .casesNav>li.current .fNav .line').css('margin-right'))) + 'px)';
                }
                $('main .cases .contnHead .casesNav .sonNavPalace.now .box').html(html);
                $('main .cases .contnHead .casesNav .sonNavPalace.now .box')[0].style.cssText = padding;
                $('main .cases .contnHead .casesNav .sonNavPalace.now').height($('main .cases .contnHead .casesNav .sonNavPalace.now .box')[0].offsetHeight);
                
            }
        }
        $(document).ready(function(){
            windowWidth = window.innerWidth;
            $('main .cases .contnHead .casesNav>li:first-child').addClass('current');
            for(var n = 0;n < $('main .cases .contnHead .casesNav>li').length;n++){
                $('main .cases .contnHead .casesNav>li')[n].ind = n;
            }
            $('main .cases .contnHead .casesNav>li .fNav').click(function(){
                if($('main .cases .contnHead .casesNav>li').length <= 1) return false;
                $('main .cases .contnHead .casesNav>li').removeClass('current');
                $(this).parent().addClass('current');
                if(window.innerWidth >= 768){
                    showSonMenu();
                }else{
                    $('main .cases .contnHead .casesNav>li .sonMenu').css('height','');
                    $(this).parent().find('.sonMenu')[0].style.height = $(this).parent().find('.sonMenu')[0].children[0].offsetHeight + 'px';
                }
            })
            showSonMenu();
            if(window.innerWidth >= 768){
                $('.grid').masonry({gutter:24});
                $('.grid')[0].gutter = 24;
            }
            else{
                $('.grid').masonry({gutter:0});
                $('.grid')[0].gutter = 0;
            }
            /*else if(window.innerWidth >= 768 && window.innerWidth <= 1024){
                $('.grid').masonry({gutter:40});
                $('.grid')[0].gutter = 40;
            }else{
                $('.grid').masonry({gutter:0});
                $('.grid')[0].gutter = 0;
            }*/
            $('.grid').masonry({
                itemSelector:'.grid-item',
                columnWidth:'.grid-sizer',
                percentPosition:true,
                resize:true
            });
            watchWindowWidth = setInterval(function(){
                if(windowWidth != window.innerWidth && window.innerWidth >= 768 && $('main .cases .contnHead .casesNav>li').length > 1){
                    $('main .cases .contnHead .casesNav>li .sonMenu').css('height','');
                    showSonMenu();
                     windowWidth = window.innerWidth;
                }else if(window.innerWidth < 768 && !$('main .cases .contnHead .casesNav>li.current .sonMenu').height()){
                    $('main .cases .contnHead .casesNav>li.current .fNav')[0].click();
                }
                if(window.innerWidth >= 768){
                    if($('.grid')[0].gutter == 24) return false;
                    $('.grid').masonry({gutter:24});
                    $('.grid')[0].gutter = 24;
                }
                else{
                    if($('.grid')[0].gutter == 0) return false;
                    $('.grid').masonry({gutter:0});
                    $('.grid')[0].gutter = 0;
                }
                /*else if(window.innerWidth >= 768 && window.innerWidth <= 1024){
                    if($('.grid')[0].gutter == 40) return false;
                    $('.grid').masonry({gutter:40});
                    $('.grid')[0].gutter = 40;
                }else{
                    if($('.grid')[0].gutter == 0) return false;
                    $('.grid').masonry({gutter:0});
                    $('.grid')[0].gutter = 0;
                }*/

                
            },10)

            var linkHref = window.location.href;
            for(var s = 0;s < $('.title .nav .sonMenu a').length;s++){
                var href = $('.title .nav .sonMenu a')[s].getAttribute('href');
                if(linkHref.indexOf(href) >= 0){
                    console.log(linkHref);
                    console.log($('.title .nav .sonMenu a:eq(' + s + ')')[0].href);
                    console.log(s);
                    $('.title .nav .sonMenu a:eq(' + s + ')').parent().addClass('current');
                    break;
                }
            }
            
            
        })